﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class Contacts : ResponseObject
    {
        private List<Contact> _Contact = new List<Contact>();
        /// <summary>
        /// 
        /// </summary>
        public List<Contact> Contact
        {
            get { return _Contact; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public Contacts(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(String jsonText)
        {
            var d = this.SetData(jsonText).ToString("data");
            var cc = JsonConvert.DeserializeObject(d) as JContainer;            

            foreach (var s in WindowsLiveClient.CreateJsonTextList(cc))
            {
                _Contact.Add(new Contact(s));
            }
        }
    }
}
